home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / GRAPHIC / GRBLOCK.H < prev    next >
C/C++ Source or Header  |  1991-12-10  |  3KB  |  91 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * GraphicBlock - an interactor that contains a picture.
  25.  */
  26.  
  27. #ifndef grblock_h
  28. #define grblock_h
  29.  
  30. #include <InterViews/interactor.h>
  31.  
  32. typedef enum Zooming { Continuous, Binary };
  33.  
  34. class Graphic;
  35. class Perspective;
  36.  
  37. class GraphicBlock : public Interactor {
  38. public:
  39.     GraphicBlock(
  40.     Sensor*, Graphic*, 
  41.     Coord pad = 0, Alignment = Center, Zooming = Continuous
  42.     );
  43.     ~GraphicBlock();
  44.  
  45.     virtual void Update();
  46.     virtual void Draw();
  47.     virtual void Adjust(Perspective&);
  48.     virtual void Reconfig();
  49.     virtual void Highlight(boolean);
  50.  
  51.     Graphic* GetGraphic();
  52.     float GetMagnification();
  53.     void SetMagnification(float);
  54.  
  55.     virtual void Invert();          /* obsolete; use Highlight */
  56. protected:
  57.     virtual void Resize();
  58.     virtual void Redraw(Coord, Coord, Coord, Coord);
  59.  
  60.     void SwapPainters();        /* background: a hack to avoid SetColors */
  61.     Painter* GetPainter();        /* in menu highlighting. */
  62.     void InvertPainter();
  63.     void Init();
  64.  
  65.     void Normalize(Perspective&);   /* normalize units */
  66.     void Align();            /* align graphic */
  67.     void Fix();                /* keep alignment fixed during resize */
  68.     float NearestPow2(float);        /* convert to nearest power of 2 */
  69.     float ScaleFactor(Perspective&);
  70.     void UpdatePerspective();       /* recalc based on graphic's bbox */
  71.  
  72.     virtual void GetGraphicBox(Coord&, Coord&, Coord&, Coord&);
  73.     virtual void Zoom(Perspective&);
  74.     virtual void Scroll(Perspective&);
  75.     virtual float LimitMagnification(float);
  76. protected:
  77.     Graphic* graphic;
  78.     Coord pad;
  79.     Alignment align;
  80.     Zooming zooming;
  81.     Coord x0, y0;                   /* graphic offset */
  82.     float mag;                /* total magnification */
  83.     Painter* alt;            /* alternate painter for drawing */
  84.     boolean highlighted;
  85. };
  86.  
  87. inline Graphic* GraphicBlock::GetGraphic () { return graphic; }
  88. inline float GraphicBlock::GetMagnification () { return mag; }
  89.  
  90. #endif
  91.